package cn.com.zsw.gblog.utils;

import com.github.dozermapper.core.Mapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: shiwangZhou
 * @Description:
 * @Date: 2020-06-23 9:06
 */
@Component
@Slf4j
public class DozerBeanUtils {
    private static Mapper mapper;

    @Autowired
    public DozerBeanUtils(Mapper mapper) {
        DozerBeanUtils.mapper = mapper;
    }

    public static <T> T copy(Object src, Class<T> targetClass) {
        return mapper.map(src, targetClass);
    }
}
